package com.gugee.tiktok.data.common.msg;

import com.gugee.tiktok.common.model.spider.market.author.Author;
import com.gugee.tiktok.data.common.util.ProtostuffUtil;
import lombok.Data;
import lombok.Getter;
import lombok.ToString;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serializer;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: luolifeng
 * Date: 2020-11-16 14:13
 */
    @Data
    @Getter
    @ToString(callSuper = true)
public class MarketMessage extends TiktokMessage {
         private Author author;



    /**
     * 任务消息的反序列号
     *
     * @author luolifeng
     * @version 1.0.0
     * Date 2020/10/04
     * Time 15:03
     */
    public static class MsgDeserializer implements Deserializer<MarketMessage> {
        @Override
        public void configure(Map map, boolean b) {

        }

        @Override
        public MarketMessage deserialize(String topic, byte[] bytes) {
            return ProtostuffUtil.deserializer(bytes, MarketMessage.class);
        }

        @Override
        public void close() {

        }
    }

    /**
     * Description 类描述
     *
     * @author luolifeng
     * @version 1.0.0
     * Date 2020/10/04
     * Time 15:12
     */
    public static class MsgSerializer implements Serializer<MarketMessage> {
        @Override
        public void configure(Map map, boolean b) {

        }

        @Override
        public byte[] serialize(String topic, MarketMessage msg) {
            return ProtostuffUtil.serializer(msg, MarketMessage.class);
        }

        @Override
        public void close() {

        }
    }

}
